﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="PreLoadViewModel.cs" company="Spenta Consulting">
//   (c) Copyright 2011
// </copyright>
// <summary>
//   PreLoad view model
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Spenta.StreetCare.Silverlight.MVVM.ViewModels
{
    using System.Windows;
    using System.Windows.Browser;

    using GalaSoft.MvvmLight.Messaging;

    using Spenta.StreetCare.Silverlight.StreetCareAPI;

    /// <summary>
    /// PreLoad view model
    /// </summary>
    public class PreLoadViewModel : BaseViewModel
    {
        /// <summary>
        /// Private store for the loading visibility property
        /// </summary>
        private Visibility loadingVisibility;

        #region Class Constructor

        /// <summary>
        /// Initializes a new instance of the <see cref="PreLoadViewModel"/> class.
        /// </summary>
        public PreLoadViewModel()
        {
            if (HtmlPage.IsEnabled)
            {
                Messenger.Default.Register<Customer>(this, (c => this.LoadingVisibility = c.IsLoaded ? Visibility.Collapsed : Visibility.Visible));
            }
        }

        #endregion

        #region ViewModel Properties

        /// <summary>
        /// Gets or sets the visibility.
        /// </summary>
        /// <value>The visibility.</value>
        public Visibility LoadingVisibility
        {
            get
            {
                return this.loadingVisibility;
            }

            set
            { 
                this.loadingVisibility = value;
                RaisePropertyChanged("LoadingVisibility");
            }
        }

        #endregion
    }
}
